#!/bin/bash

LOG="$HOME/.xbmc/userdata/addon_data/service.system.wakeup/logging.log"
LOG_DIR=`dirname $LOG`

if [ ! -d $LOG_DIR ];then
	mkdir -p $LOG_DIR
fi

echo "["`date "+%Y-%m-%d %H:%M:%S"`"]" >> $LOG

#echo "removing modules" >> $LOG
#rmmod h826d >> $LOG
#rmmod dvb-core >> $LOG
#rmmod v4l2-common >> $LOG
#rmmod nvidia >> $LOG

echo "started shutdown sequence" >> $LOG
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo "wakeup command: echo $1 > /sys/class/rtc/rtc0/wakealarm" >> $LOG
echo $1 > /sys/class/rtc/rtc0/wakealarm
echo "suspending" >> $LOG
/usr/sbin/pm-suspend
